<?php

namespace app\common\validate;

class AdminValidate extends BaseValidate
{
    /**
     * 验证规则
     *
     * @var array
     */
    protected $rule = [
        'id'           => 'integer|gt:0',
        'username'     => 'require|alphaDash|length:4,20|unique:admin,username,0,id',
        'password'     => 'require|min:6|confirm',
        'group_id'     => 'require|integer|gt:0',
        'nickname'     => 'require|max:50|unique:admin,nickname,0,id',
        'head_pic'     => 'require',
        'status'       => 'in:0,1',
        'password_old' => 'min:6',
        'account'      => 'max:80',
        'platform'     => 'max:50',
        'refresh'      => 'length:32',
        'page_index'   => 'require|integer|gt:0',
        'page_size'    => 'require|integer|gt:0',
        'order_type'   => 'requireWith:order_field|in:asc,desc',
        'order_field'  => 'requireWith:order_type|in:id,username,group_id,nickname,last_login,status,create_time,update_time',
    ];
    /**
     * 验证规则
     */
    protected $field = [
        'username'    => '账号',
        'password'    => '密码',
        'group_id'    => '用户组Id',
        'nickname'    => '昵称',
        'head_pic'    => '头像',
        'last_login'  => '最后登录日期',
        'last_ip'     => '最后登录ip',
        'status'      => '状态',
        'is_delete'   => '删除',
        'create_time' => '创建日期',
        'update_time' => '更新日期',

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'     => [
            'username'         => 'require|alphaDash|length:4,20|unique:admin,username,0,admin_id',
            'password'         => 'require|min:6',
//            'password_confirm' => 'min:6|confirm',
            'group_id'         => 'require|integer|gt:0',
            'nickname'         => 'require|max:50|unique:admin,nickname,0,admin_id',
            'head_pic'       ,
            'status'           => 'in:0,1',
            'sex'           => 'in:0,1',
            'mobile'           => 'require|mobile',
            'store_ids'        => 'array',
            'skill_level'        => 'integer',
            'admin_tag'        => 'array',
        ],
        'set'     => [
            'admin_id' => 'require|integer|gt:0',
            'nickname' => 'max:50',
            'mobile'   => 'mobile|require',
            'group_id',
            'head_pic',
        ],
        'status'  => [
            'admin_id' => 'require|arrayHasOnlyInts',
            'status'   => 'require|in:0,1',
        ],
        'change'  => [
            'admin_id'     => 'require|integer|gt:0',
            'password',
            'password_old' => 'require|min:6',
        ],
        'reset'   => [
            'admin_id' => 'require|integer|gt:0',
        ],
        'del'     => [
            'admin_id' => 'require',
        ],
        'item'    => [
            'admin_id' => 'require|integer|gt:0',
        ],
        'list'    => [
            'admin_id' => 'arrayHasOnlyInts',
            'account',
            'group_id' => 'integer|gt:0',
            'keyword',
            'status',
            'page_index',
            'page_size',
            'order_type',
            'order_field',
        ],
        'select'  => [
            'admin_id' => 'require|arrayHasOnlyInts',
        ],
        'login'   => [
            'username' => 'require|alphaDash|length:4,20',
            'password' => 'require|min:6',
            'platform' => 'require|min:4|max:50|in:platform,store,work',
        ],
        'setPasswordByMobile'=>[
            'mobile'=>'mobile|require',
            'code'=>'require|integer|length:4',
            'password'=>'require|confirm',
            'password_confirm'=>'require',
        ],
        'refresh' => [
            'refresh' => 'require|length:32',
        ],
    ];


}
